
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/axios-0.20.0.js"></script>
    <%--
        1.引入axios.js文件
            碰到引入不进来静态资源的问题  在spring-mvc.xml中配置如下代码
            <mvc:default-servlet-handler></mvc:default-servlet-handler>
        2.编写ajax请求
    --%>
    <script>
        function btnClick(){
            //参数1: url
            //参数2: json字符串
            //axios.get( url , params:{key:value,key:value} ).then(resp=>{});

            let params = {username:'jack' , password:'1234' , age: 18};
            axios.post("/ajax" ,params ).then(resp=>{
                console.log(resp.data);//输出数据层面
            });
        }
    </script>
</head>
<body>
    <input type="button" value="点我发送ajax请求" onclick="btnClick()"/>
</body>
</html>
